
package nc.bs.pub.action;

import nc.bs.framework.common.NCLocator;
import nccloud.bs.rongq.bill.aggbusi.plugin.bpplugin.CenterVOPluginPoint;
import nc.bs.pubapp.pf.action.AbstractPfAction;
import nc.bs.pubapp.pub.rule.CommitStatusCheckRule;
import nc.impl.pubapp.pattern.rule.IRule;
import nc.impl.pubapp.pattern.rule.processer.CompareAroundProcesser;
import nccloud.itf.rongq.bill.ICentervoMaintain;
import nc.vo.rongq.lrcenter.AggCenterVO;
import nc.vo.pub.BusinessException;
import nc.vo.pubapp.pattern.exception.ExceptionUtils;

public class N_CENT_SAVE extends AbstractPfAction<AggCenterVO> {

        protected CompareAroundProcesser<AggCenterVO> getCompareAroundProcesserWithRules(
                        Object userObj) {
                CompareAroundProcesser<AggCenterVO> processor = new CompareAroundProcesser<AggCenterVO>(
                CenterVOPluginPoint.SEND_APPROVE);
                // TODO 在此处添加审核前后规则
                IRule<AggCenterVO> rule = new CommitStatusCheckRule();
                processor.addBeforeRule(rule);
                return processor;
        }

        @Override
        protected AggCenterVO[] processBP(Object userObj,
                        AggCenterVO[] clientFullVOs, AggCenterVO[] originBills) {
                ICentervoMaintain operator = NCLocator.getInstance().lookup(
                                ICentervoMaintain.class);
                AggCenterVO[] bills = null;
                try {
                        bills = operator.save(clientFullVOs, originBills);
                } catch (BusinessException e) {
                        ExceptionUtils.wrappBusinessException(e.getMessage());
                }
                return bills;
        }

}
